package com.lll.springbootkafka.kafka.bean.consumer;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
 * Description: 用户日志消息消费者<br/>
 *
 * @author LLL<br       />;
 * @taskId <br/>
 * consumer消费者 <br/>
 */
@Slf4j
@Component
public class UserLogConsumer {

    @KafkaListener(topics = { "user-log" })
    public void consume(ConsumerRecord<?, ?> consumerRecord) {
        if (!Objects.isNull(consumerRecord.value())) {
            log.info(">>>>>>>>>>>>Kafka message is {}", consumerRecord.value().toString());
            System.out.println("message: " + consumerRecord.value());
        }
    }
}
